import speech_recognition as sr
from aip import AipSpeech
import json
import requests


# 图灵机器人对话
tulingurl="http://openapi.tuling123.com/openapi/api/v2"
appkey="4ee411e75a23472e9721f1d7c9a47e7f"
# tulingurl="http://api.tianapi.com/txapi/robot/index"
# appkey="e51daa13fc3937302ae3a38caed0520f"
def robot2(txt):
    say=txt
    jsonParam={
	"reqType":0,
    "perception": {
        "inputText": {
            "text": say
        },
        "inputImage": {
            "url": "imageUrl"
        },
        "selfInfo": {
            "location": {
                "city": "泰安",
                "province": "山东",
                "street": "凤凰路"
            }
        }
    },
    "userInfo": {
        "apiKey": appkey,
        "userId": "tutu"
    }
    }
    res=requests.post(tulingurl,None,jsonParam)
    tulingsay=json.loads(res.text)
    print(tulingsay)
    print(tulingsay["results"][0]["values"]["text"])
    return tulingsay["results"][0]["values"]["text"]

